Repository navigation
perf(atlas-search): run hybrid branches concurrently (#12900 thread 1) - #13039
Merged
Merged
Conversation
The FTS and vector branches of a hybrid query are independent and join only at RRF fusion, but run_search executed them strictly serially on every backend shape: the local FTS query finished before the vector scan started, the turso index path ran its FTS pipeline to completion before the index branch, and the turso scan path sent both statements in one pipeline, which executes sequentially server-side. They now run concurrently through run_branches (a thread pool, results collected by name; a single branch still runs inline, so fts-only and vector-only keep their exact old shape). LocalBackend gives each thread its own sqlite connection — the TEMP views of _setup_views and the ATTACHes of load_matrix are per-connection state — so branch workers never share one. die() inside a branch is ferried back and re-raised as SystemExit on the calling thread with its exit code intact. Output is unchanged: fixtures/gen_core_fixtures.py regenerated against this code produces a core-expectations.json value-identical to the committed recording, and the new tests in tests/test_branch_concurrency.py pin serial == concurrent == recorded envelopes, real overlap under slowed branch entry points, and die() propagation on both backend shapes. Refs #12900
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 23 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #12900 — thread 1 of 3 (parallel branch execution in the Python CLI). The issue stays open: thread 2 is a product decision (multi-client service shape) and thread 3 is the nix-packaged binary swap.
What changed (
pkgs/atlas-search/atlas_search.py)A hybrid query's FTS and vector branches are independent and join only at RRF fusion, but
run_searchexecuted them strictly serially on every backend shape. Now:run_brancheshelper: with two or more branches they run concurrently on a thread pool and are collected by name — fusion order, and therefore the output envelope, is unchanged. A single branch runs inline, so fts-only / vector-only keep their exact old shape.die()in a branch is ferried back and re-raised asSystemExiton the calling thread with its exit code intact.turso_index_branchnow overlap.LocalBackend.conis now a per-thread connection (property + thread-local). The TEMP views of_setup_viewsand the ATTACHes ofload_matrixare per-connection state, so branch workers each get their own connection with the same view setup instead of sharing one.Verification
pkgs/atlas-search/tests/test_branch_concurrency.py(5 tests, all passing on the laptop with the v3-venv python): hybrid envelope concurrent == forced-serial == the committed recording infixtures/core-expectations.json; fts-only and vector-only envelopes match their recordings; with 0.6 s sleeps injected at both branch entry points the serial shape takes ≥1.15 s and the concurrent shape <1.0 s;die()inside a branch surfaces asSystemExitwith its code on both the local and turso paths.fixtures/gen_core_fixtures.pyre-run against this code: the regeneratedcore-expectations.jsonis value-identical to the committed recording (all 12 search cases, get-chunk cases, and the turso SQL fixtures) — the file itself is not in this PR.tools/testssuites still pass (test_disclosure 8, test_note_promotion_sweep 5).Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.